﻿using Microsoft.AspNetCore.Hosting;
using Simple.Entity.Entity;
using Simple.Entity.View;
using Simple.IRepository;
using Simple.Tools;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simple.Repository
/// <summary>
/// 版 本 钢易智企2.0 V 2.0.0 钢易智企2.0
/// Copyright (c) 2023 杭州钢易科技有限公司
/// 创建人：曾东明
/// 日 期：2024
/// 描 述：
/// </summary>
{
	public class UserRepository : WholeRepository<SysUserEntity, long>, IUserRepository
	{
		public UserRepository()
		{

		}

		public ISugarQueryable<UserView> Query(Action<ISugarQueryable<SysUserEntity>> matchCondition)
		{
			var query=dbClient.Queryable<SysUserEntity>();

			SimpleCheck.IsNullThrowException(matchCondition);

			matchCondition.Invoke(query);

			return query.Select(user => new UserView()
			{
				Id=user.Id.ToString(),
				Account=user.Account,
				Age=user.Age,
				UserName=user.UserName,
			});
		}

	}
}
